<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" id="vp"/>
{#        <script type="text/javascript" src="/static/js/rem.js"></script>#}
{#        <link rel="stylesheet" type="text/css" href="/static/css/base.css" />#}
{#        <link rel="stylesheet" type="text/css" href="/static/css/index.css" />#}
    </head>
    <body>
        <div class="bigbox">
            <div class="top">
                <br>订单详情:</br>
                <br>订单号: {{ out_trade_no }}</br>
                <br>时间：{{ timestamp }}</br>
                <span> 点击支付发起微信支付</span>

                <br>金额：{{ fee }}</br>

                <br>感谢您的支持</br>
            </div>
            <div class="zhong">

            </div>

            <div class="zhifu">
                <button class="btn" type="button" onclick="javascript:callpay();return false;">立即支付</button>
            </div>

        </div>

<script type="text/javascript">
    //调用微信JS api 支付
    function onBridgeReady() {
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',
            {
                appId: "{{ app_id }}",        //公众号名称，由商户传入
                timeStamp: "{{ timestamp }}", //时间戳，自1970年以来的秒数
                nonceStr: "{{ nonceStr }}",  //随机串
                package: "{{ package }}",  //预支付id
                signType: "{{ sign_type }}",  //微信签名方式
                paySign: "{{ pay_sign }}"     //微信签名
            },
            function (res) {
                //支付成功后返回 get_brand_wcpay_request:ok
                if (res.err_msg == "get_brand_wcpay_request:ok") {
                    // 跳转到支付成功的页面
                    window.location.href = '#';
                    {#alert('支付成功');#}
                } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
                    alert("您已取消支付!");
                    {#alert({{ machine_code }});#}
                    {#window.location.href = '';#}
                } else if (res.err_msg == "get_brand_wcpay_request:fail") {
                    $.each(res, function(key,value){
                        alert(value);
                        });
                    alert("支付失败!");
                }
            }
        );
    }

    function callpay() {
        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        } else {
            onBridgeReady();
        }
    }

</script>
    </body>
</html>
